/**
 * Gameloop.h
 *
 *  Created on: 2-dec.-2013
 *      Author: Axel
 */

#ifndef GAMELOOP_H_
#define GAMELOOP_H_

#include "Window.h"

#include <GL/glew.h>
#include <glfw3.h>
#include <ctime>
#include "StateMachine.h"
#include "StateManager.h"
#include "LoadShader.h"

/**
 * Class that handles the game loop
 */
class Gameloop {
public:
	/**constructor and destructor*/
	Gameloop();
	virtual ~Gameloop();

	/**the core gameloop function*/
	void gameLoop();

private:
	/**the game window*/
	Window* window;

	/**simple vars*/
	long lastFrame;
	bool running;

	/**the fps and timer*/
	static const double FPS;
	static int timer;

	/**holding the currentstate and the manager*/
	StateMachine* currentState;
	StateManager* manager;

	/**get the time*/
	long getTime();
	/**stop the loop*/
	void stopLoop();

	/**update the game*/
	void update();
	/**render the game*/
	void render(float interpolation);
	/**handle input*/
	void handleInput();
	/**change the state*/
	void changeState(StateMachine* level);
};

#endif /* GAMELOOP_H_ */
